#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>
using namespace std;

//96.11 %
class Solution
{
  public:
	vector<int> twoSum(vector<int> &nums, int target)
	{
		unordered_map<int, int> record;
		for (int i = 0; i < nums.size(); i++)
		{
			int complement = target - nums[i];
			if (record.find(complement) != record.end())
			{
				int res[2] = {record[complement], i};
				return vector<int>(res, res + 2);
			}
			record[nums[i]] = i;
		}
	}
};
int main()
{
	int nums[] = {2, 7, 11, 15}, target = 9, length = sizeof(nums) / sizeof(nums[0]);
	vector<int> myVec(nums, nums + length);
	vector<int> re = Solution().twoSum(myVec, target);
	cout << re[0] << " " << re[1] << endl;
	return 0;
}
